package com.hspedu.homework.homwork01;

public class Person {
   private final String name;
    private  Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }

    public void passriver(){
  //得到船
        if(!(vehicles instanceof Boat)){

            vehicles=VehiclesGC.getboat();
        }
        vehicles.work();

    }

    public void common(){
    //得到马儿
        if(vehicles==null)
        {
        vehicles=VehiclesGC.gethorse();}

        vehicles.work();
    }
}
